package adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;

import bean.CheckPlace;

/**
 * Created by aaa on 15-4-28.
 */
public class CheckPlaceAdapter extends BaseAdapter{
    private ArrayList<CheckPlace> data;
    private LayoutInflater inflater;
    private Context context;

    public CheckPlaceAdapter(ArrayList<CheckPlace> data, Context context) {
        this.data = data;
        this.context = context;
        inflater=LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        if (data!=null){

            return data.size();
        }
        return 0;

    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if (convertView==null){
            convertView = inflater.inflate(android.R.layout.simple_list_item_1, null);
            holder=new ViewHolder();
            holder.cityName= (TextView) convertView.findViewById(android.R.id.text1);
            convertView.setTag(holder);
        }else{
            holder= (ViewHolder) convertView.getTag();
        }

        holder.cityName.setText(data.get(position).getCityName());
        return convertView;
    }
    class ViewHolder{
        TextView cityName;
    }
}
